﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TransactionRecord.aspx.cs" Inherits="YY.Web.MyAgent.financial_information.TransactionRecord" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>交易记录</title>
    <link type="text/css" href="/css/finance.css" rel="stylesheet" />
    <link type="text/css" href="/css/common.css" rel="stylesheet" />
    <script src="/Jquery/jquery-1.8.3.min.js"></script>
    <script src="/Jquery/jquery.page.js"></script>
    <script src="/Jquery/Common.js"></script>
    <script type="text/javascript">
        function SearchInforByPageIndex(pageindex) {
            var starttime = $("#txt_StartTime").val();
            var endtime = $("#txt_EndTime").val();
            var strstatus = $("#Select_Status").val();
            var today = $("#today").attr("class");
            var week = $("#week").attr("class");
            var month = $("#month").attr("class");
            var threemonth = $("#threemonth").attr("class");
            var type = $(".trade-sort").find('.on').attr("id");
            //查询数据
            $.post("FinanceHandler.ashx?action=GetTradeRecordByPage", { "page": pageindex, "rows": 10, "StartTime": starttime, "EndTime": endtime, "type": type, "Status": strstatus, "today": today, "week": week, "month": month, "threemonth": threemonth }, function (data, status) {
                if (status == "success") {
                    if (data == "1000") {
                        window.location.href = "ErrorInfor.aspx";
                    }
                    else {
                        var infor = JSON.parse(data);
                        if (infor.length < 1) {
                            $(".tradelist").html("<img alt='' src='/Images/None1.png' style='margin-left:170px;margin-top:100px;;margin-bottom:100px;' />");
                            $("#div_page").hide();
                        }
                        else {
                            var htmlstring = "<table border='0' width='1120' border='0' cellspacing='0' cellpadding='0'>";
                            htmlstring += "<tr><td class='jy-tit' width='20%'>创建时间</td><td class='jy-tit' width='30%'>名称</td><td class='jy-tit' width='12%'>金额(元)</td><td class='jy-tit' width='19%'>对方名称</td><td class='jy-tit'>交易状态</td></tr>";
                            for (var i = 0; i < infor.length; i++) {
                                if (i % 2 == 0) {
                                    htmlstring += "  <tr bgcolor='#fff'><td>" + infor[i].TradeTime.toString().substring(0, 10).replace('/', '-').replace('/', '-') + "</br>" + infor[i].TradeTime.toString().substring(11, 19) + "</td>";
                                    htmlstring += "  <td class='mc'><a href='TransactionRecordsDetail.aspx?Id=" + infor[i].ID + "' >" + infor[i].TradeContent + "</a></td>"
                                    htmlstring += " <td>" + infor[i].Fund.split(',')[0] + "</td>";
                                    htmlstring += "  <td>" + infor[i].OtherName + "</td>";
                                    htmlstring += "  <td>" + infor[i].Status + "</td></tr>";
                                }
                                else {
                                    htmlstring += "  <tr bgcolor='#e6f5ff'><td>" + infor[i].TradeTime.toString().substring(0, 10).replace('/', '-').replace('/', '-') + "</br>" + infor[i].TradeTime.toString().substring(11, 19) + "</td>";
                                    htmlstring += "  <td class='mc'><a href='TransactionRecordsDetail.aspx?Id=" + infor[i].ID + "'>" + infor[i].TradeContent + "</a></td>"
                                    htmlstring += " <td>" + infor[i].Fund.split(',')[0] + "</td>";
                                    htmlstring += "  <td>" + infor[i].OtherName + "</td>";
                                    htmlstring += "  <td>" + infor[i].Status + "</td></tr>";
                                }
                            }
                            htmlstring += "</table>";
                            $(".tradelist").html(htmlstring);
                        }
                    }
                }
            });
        }

        function SearchInfor(i) {
            $(i).attr("class", "on");
            var typename = $(i).html();
            if (typename == "今天") {
                $("#txt_StartTime").val(CurentTime());
                $("#txt_EndTime").val(CurentLastDay());
            }
            if (typename == "最近一周") {
                $("#txt_StartTime").val(CurentLastWeek());
                $("#txt_EndTime").val(CurentTime());
            }
            if (typename == "最近30天") {
                $("#txt_StartTime").val(CurentLastMonth());
                $("#txt_EndTime").val(CurentTime());
            }
            if (typename == "最近3个月") {
                $("#txt_StartTime").val(CurentLastthreeMonth());
                $("#txt_EndTime").val(CurentTime());
            }
            $($(i).siblings()).attr("class", "off");
            GetTradeRecordCountByPage();
            SearchInforByPageIndex(1);
        }

        function SearchRecord() {
            GetTradeRecordCountByPage();
            SearchInforByPageIndex(1);
        }

        function GetAllTradeType(k) {
            $.post("FinanceHandler.ashx?action=GetAllTradeType", function (data, status) {
                if (status == "success") {
                    var infor = JSON.parse(data);
                    if (k == 1) {
                        var htmlstr = "";
                        $("#alltype").attr("class", "off");
                        for (var j = 0; j < infor.length; j++) {
                            if (infor[j].DataName == "提现") {
                                htmlstr += "<a  id='" + infor[j].ID + "' href='javascript:;' class='on' onclick='SearchInfor(this)' >" + infor[j].DataName + "</a>";
                            }
                            else {
                                htmlstr += "<a  id='" + infor[j].ID + "' href='javascript:;' class='off' onclick='SearchInfor(this)' >" + infor[j].DataName + "</a>";
                            }
                        }
                        var htmlvalue = $(".trade-sort").html();
                        $(".trade-sort").html(htmlvalue + htmlstr);
                    }
                    else {
                        var htmlstring = "";
                        for (var i = 0; i < infor.length; i++) {
                            htmlstring += "<a  id='" + infor[i].ID + "' href='javascript:;' class='off' onclick='SearchInfor(this)' >" + infor[i].DataName + "</a>";
                        }
                        var htmlvalue = $(".trade-sort").html();
                        $(".trade-sort").html(htmlvalue + htmlstring);
                    }
                }
            });
        }

        function GetTradeRecordCountByPage() {
            var starttime = $("#txt_StartTime").val();
            var endtime = $("#txt_EndTime").val();
            var strstatus = $("#Select_Status").val();
            var today = $("#today").attr("class");
            var week = $("#week").attr("class");
            var month = $("#month").attr("class");
            var threemonth = $("#threemonth").attr("class");
            var type = $(".trade-sort").find('.on').attr("id");
            $.post("FinanceHandler.ashx?action=GetTradeRecordCountByPage", { "rows": 10, "StartTime": starttime, "EndTime": endtime, "Status": strstatus, "today": today, "week": week, "month": month, "threemonth": threemonth, "type": type }, function (data, status) {
                if (status == "success") {
                    if (data == "1000") {
                        window.location.href = "ErrorInfor.aspx";
                    }
                    else {
                        var infor = data;
                        if (infor == "1" || infor == "0") {
                            $("#div_page").hide();
                        }
                        else {
                            $("#div_page").show();
                        }
                        $('.tcdPageCode').unbind('click').click(function () {

                        });
                        $(".tcdPageCode").createPage({
                            pageCount: infor,
                            current: 1,
                            backFn: function (p) {
                                SearchInforByPageIndex(p);
                            }
                        });
                    }
                }
            });
        }

        function TimeOnChange() {
            var starttime = $("#txt_StartTime").val();
            var endtime = $("#txt_EndTime").val();
            var CurentTimevalue = CurentTime();
            var CurentLastDayvalue = CurentLastDay();
            var CurentLastWeekvalue = CurentLastWeek();
            var CurentLastMonthvalue = CurentLastMonth();
            var CurentLastthreeMonthvalue = CurentLastthreeMonth();

            if (starttime == CurentTimevalue && endtime == CurentLastDayvalue) {

            }
            else if (starttime == CurentLastWeekvalue && endtime == CurentTimevalue) {

            }
            else if (starttime == CurentLastMonthvalue && endtime == CurentTimevalue) {

            }
            else if (starttime == CurentLastthreeMonthvalue && endtime == CurentTimevalue) {

            }
            else {
                //清空其他时间选中的样式
                $(".time-xz a").attr("class", "off");
            }
            SearchInforByPageIndex(1);
            GetTradeRecordCountByPage();
        }

        $(function () {
            var url = window.location.search;
            var loc = url.substring(url.lastIndexOf('=') + 1, url.length);
            GetAllTradeType(loc);
            $("#txt_StartTime").val(CurentLastWeek());
            $("#txt_EndTime").val(CurentTime());
            SearchInforByPageIndex(1);
            GetTradeRecordCountByPage();
        });
    </script>
    <link href="/css/datepicker.css" rel="stylesheet" />
    <script src="/jQuery/bootstrap-datepicker.js"></script>
    <script type="text/javascript">
        $(function () {
            $('.time-input').datepicker()
            .on('changeDate', function (ev) {
                TimeOnChange();
            });
        });
    </script>
    <style type="text/css">
        .tcdPageCode a {
            text-decoration: none;
            color: #5f6362;
            border: 1px solid #b3dabd;
            height: 35px;
            line-height: 35px;
            background: url(/images/page-bg.gif) repeat-x;
            float: left;
            padding: 0px 14px;
            margin-right: 5px;
            font-size: 14px;
        }

        .tcdPageCode .disabled {
            color: #5f6362;
            border: 1px solid #b3dabd;
            height: 35px;
            line-height: 35px;
            background: url(/images/page-bg.gif) repeat-x;
            float: left;
            padding: 0px 14px;
            margin-right: 5px;
            font-size: 14px;
        }

        .tcdPageCode span {
            color: #5f6362;
            border: 0px solid #b3dabd;
            height: 35px;
            line-height: 35px;
            float: left;
            padding: 0px 14px;
            margin-right: 5px;
            font-size: 14px;
            color: #CCC;
        }
    </style>
</head>
<body style="background-color: #f5f5f5;">
    <form id="form1" runat="server">
        <!--content begin-->
        <div class="wrap jy-bg">
            <div class="trade-bt w1120 clearfix">
                <div class="trade-icon"></div>
                <div class="trade-tit"><a href="javascript:;" class="cur">交易记录</a></div>
            </div>
        </div>
        <!--交易记录-->
        <div class="trade-con">
            <span style="font-size: 24px; color: #333;">&nbsp;</span>
            <div class="trade-search">
                <ul>
                    <li><span>起止时间：</span><span><input id="txt_StartTime" type="text" value="" class="time-input" style="width: 192px;"  data-date-format="yyyy-mm-dd" onblur="TimeOnChange()" />-<input id="txt_EndTime" type="text" value="" class="time-input" style="width: 192px;"  data-date-format="yyyy-mm-dd"  onblur="TimeOnChange()" /></span>
                        <span class="time-xz">
                            <a id="today" href="javascript:;" class="off" onclick="SearchInfor(this);">今天</a>
                            <a id="week" href="javascript:;" class="on" onclick="SearchInfor(this);">最近一周</a>
                            <a id="month" href="javascript:;" class="off" onclick="SearchInfor(this);">最近30天</a>
                            <a id="threemonth" href="javascript:;" class="off" onclick="SearchInfor(this);">最近3个月</a>
                        </span>
                    </li>
                    <li><span>交易状态：</span><span><select id="Select_Status" name="" onchange="SearchRecord();">
                        <option value="1">交易成功</option>
                        <option value="-1">交易中</option>
                        <option value="0">交易失败</option>
                        <option selected="selected" value="2">全 部</option>
                    </select></span></li>
                    <li><span>交易分类：</span>
                        <span class="trade-sort">
                            <a id='alltype' href='javascript:;' class='on' onclick='SearchInfor(this)' >全部</a>
                        </span>
                    </li>
                </ul>
            </div>
            <div class="tradelist">
            </div>
            <div id="div_page" class="tcdPageCode" style="width: 55%; margin-left: auto; margin-right: auto; margin-top: 30px;"></div>
        </div>
        <!--充值记录-->
        <div class="trade-con" style="display: none;"></div>
        <!--提现记录-->
        <div class="trade-con" style="display: none;"></div>
        <!--content end-->
    </form>
</body>
</html>